<script setup lang="tsx">
import { message } from "@/utils/message";
import { type PlusColumn, PlusDescriptions } from "plus-pro-components";
const prop = defineProps({
  info: {
    default: () => []
  }
});
function handleCellDbClick(row) {
  navigator.clipboard.writeText(row.goodsNo);
  message(`复制货物编号成功`, {
    type: "success"
  });
}
//发货单列表
const columns: PlusColumn[] = [
  {
    label: "订单编号",
    prop: "orderNum",
    valueType: "copy"
  },
  {
    label: "货物目的地",
    prop: "goodsDest"
  },
  {
    label: "提货日期",
    prop: "deliveryDate"
  },
  {
    label: "企业全称",
    prop: "corp.name"
  },
  {
    label: "企业负责人",
    prop: "principal"
  },
  {
    label: "状态",
    prop: "statusFormat"
  },
  {
    label: "创建时间",
    prop: "createdAt"
  },
  {
    label: "货物信息",
    prop: "orderGoods",
    width: 200
  },
  {
    label: "车辆信息",
    prop: "orderVehicle",
    width: 200
  },
  {
    label: "发货备注",
    prop: "remarks"
  }
];
//商品列表
const goodsColumns: TableColumnList = [
  {
    label: "货物名称",
    prop: "goodsName"
  },
  {
    label: "货物编号",
    prop: "goodsNo",
    minWidth: 135
  },
  {
    label: "分类",
    prop: "category"
  },
  {
    label: "价格",
    prop: "goodsCost"
  },
  {
    label: "货物描述",
    prop: "goodsSpec"
  }
];
//车辆列表
const vehicleColumns: TableColumnList = [
  {
    label: "车牌号",
    prop: "vehicleInfo.number"
  },
  {
    label: "驶入时间",
    prop: "entryStartTime"
  },
  {
    label: "驶出时间",
    prop: "entryEndTime"
  },
  {
    label: "状态",
    prop: "entryStatus",
    formatter(row, column, cellValue) {
      switch (cellValue) {
        case 0:
          return "未审核";
        case 1:
          return "审核成功";
        case 2:
          return "审核失败";
      }
    }
  },
  {
    label: "货物描述",
    prop: "goodsSpec"
  }
];
</script>

<template>
  <PlusDescriptions
    title="提货单详情"
    :column="1"
    :columns="columns"
    :data="prop.info[0]"
  >
    <template #plus-desc-orderGoods="{ value }">
      <pure-table
        :data="value"
        :columns="goodsColumns"
        @cell-dblclick="handleCellDbClick"
      />
    </template>
    <template #plus-desc-orderVehicle="{ value }">
      <pure-table :data="value" :columns="vehicleColumns" />
    </template>
  </PlusDescriptions>
</template>
